<template>
  <div  class="app-container"  v-loading="loading">
    <el-container>
    <el-main style="width: 90vw;height: 80vh;">
<!--      <el-tabs v-model="activeName" >-->
        <video-publish></video-publish>
<!--        &lt;!&ndash;      单账号视频一键发布  &ndash;&gt;-->
<!--        <el-tab-pane label="单视频发布" name="one">-->
<!--              <video-publish></video-publish>-->
<!--        </el-tab-pane>-->
<!--        &lt;!&ndash;        视频模板发布&ndash;&gt;-->
<!--        <el-tab-pane label="分组账号一键发布" name="two">-->
<!--&lt;!&ndash;          <group-publish></group-publish>&ndash;&gt;-->
<!--          暂未开放,预计29日前完成功能开发。-->
<!--        </el-tab-pane>-->
<!--&lt;!&ndash;        视频分组模板发布&ndash;&gt;-->
<!--        <el-tab-pane label="视频号模板发布" name="three">-->
<!--&lt;!&ndash;          <model-publish></model-publish>&ndash;&gt;-->
<!--          暂未开放,预计29日前完成功能开发。-->
<!--        </el-tab-pane>-->
<!--      </el-tabs>-->
    </el-main>

    </el-container>

  </div>
</template>

<script>

import { listMediaAccount } from "@/api/media/mediaAccount";
import { publishVideo } from "@/api/media/channelsPublish";
import videoPublish from "./videoPublish/index"   //视频发布
import modelPublish from "./modelPublish/index"   //模板视频发布
import groupPublish from "./groupPublish/index"  //分组发布
import {Message} from "element-ui";

import { listPublishRecord, addPublishRecord} from "@/api/media/publishRecord";
import store from "@/store";
import { serviceInvoke } from "@/utils/ipcRenderer";
export default {
  name: "Account",
  components:{
    videoPublish,
    modelPublish,
    groupPublish
  },
  data() {
    return {
      buttonLoading:false,
      checkAccountVisable:false,
      percent: 50, // the percentage of the progress bar
      color: '#409EFF', // the color of the progress bar
      strokeWidth: 15, // the width of the progress bar stroke
      loading:false,
      total:0,
      accUser:[],
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      activeName:'one',
      checkAll: false,
      currentRow:{},
      form:{
        link:undefined,
        publishType:'1',
        description:undefined,
        accountId:undefined,
        publishTime:undefined,
        filePath: undefined,
        shortTitle:undefined,
        mode:'0'
      },
      dialogVisible:false,
      publishTime:'',
      rules:{
        accountId: [
          { required: true, message: "账号不能为空", trigger: "blur" }
        ],
        filePath:[
          { required: true, message: "视频文件不能为空", trigger: "blur" }
        ],
        publishTime:[
        { required: true, message: "发布时间不能为空", trigger: "blur" }
        ]
      },
      queryParams:{},
      dir_path:'',
      isIndeterminate: true,
      accountList:[]
    };
  },
  created() {
    // this.getList();
  },
  methods: {

    /**
     * 选择账号时弹框选择对应账号
     */
    selectAccount(){
      this.checkAccountVisable = true;
    },

    /**
     * 重置按钮
     */
    resetQuery(){
      this.queryParams = {}
        this.getList()
    },

    handleCheckClose(){

    },

    /**
     * 选中账号信息
     */
    checkAccountData(){
      if(this.currentRow.loginStatus === 0){
        Message.error("当前选中账号已掉线，请登录后操作！")
        return;
      }
      console.log(this.currentRow)
      this.checkAccountVisable = false;
      console.log(this.ids)
    },

    /**
     * 关闭表格弹框
     */
    cancel(){
      this.checkAccountVisable =  false
    },

    /** 查询账号管理列表 */
    // getList() {
    //   this.loading = true;
    //   this.queryParams.platformCode = 'wxsph'
    //   listMediaAccount(this.queryParams).then(response => {
    //     this.accountList = response.rows;
    //     this.total = response.total;
    //     this.loading = false;
    //   });
    // },

    /**
     * 选择是否原创发布
     */
    showOriginalityDialog(){
        this.$confirm('原创内容将受平台保护，盗用原创内容将受到平台处罚。', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.form.mode = '1';
        }).catch(() => {
          this.form.mode = '0';
        });
    },


    // 多选框选中数据
    handleSelectionChange(val) {
      if(val.loginStatus === 0){
        Message.error("当前选中账号已掉线，请登录后操作！")
        return;
      }
      this.currentRow = val;
      // this.checkAccountVisable = false;
    },


    /**
     * 选择文件夹
     */
    async selectDir(num) {
      const self = this;
      if(num === 1){
        const result =  await  this.serviceInvoke("controller.example.selectFolder",2) //文件上传
        this.form.filePath = result.path
      }else{
        const result =  await  this.serviceInvoke("controller.example.selectFolder",1)  //文件夹上传
        this.form.filePath = result.path
      }
    },

    // 表单重置
    reset() {
      this.form = {
        link:undefined,
        publishType:'1',
        description:undefined,
        accountId:undefined,
        publishTime:undefined,
        filePath: undefined,
        shortTitle:undefined,
        mode:'0'
      };
    },

    /**
     * 改变行样式
     * @param row
     * @param rowIndex
     */
    rowStyle({row, rowIndex}){
      if(this.currentRow.id === row.id){
        return 'checked'
      }else{
        return 'noChecked'
      }
    },



    /**
     * 发布视频
     */
  //  async  submitForm(){
  //     if(!this.currentRow.id){
  //       Message.error("请选择账号！")
  //       return;
  //     }
  //     if(!this.form.filePath){
  //       Message.error("请选择视频文件！")
  //       return;
  //     }
  //     if(this.form.publishType ===  '2' && !this.form.publishTime){
  //       Message.error("请选择发布时间！")
  //       return;
  //     }
  //       // let args = {
  //       //   username:store.getters.name,  //添加队列用不到，发布接口需要
  //       //   accountId:this.currentRow.id,
  //       //   filePath:this.form.filePath,
  //       //   description:this.form.description,
  //       //   link:this.form.link,
  //       //   shortTitle:this.form.shortTitle,
  //       //   mode:this.form.mode,
  //       //   effectiveTime: this.form.publishTime ? Number(this.form.publishTime.getTime() / 1000) : undefined
  //       // }
  //     console.log(this.form)
  //     console.log(this.currentRow)
  //     let cookie = this.resetCookie(this.form.cookies);
  //     console.log(cookie)
  //     // let args = {
  //     //   cookies: this.convertCookies(account.cookies),
  //     //   _log_finder_id: account.finderUsername,
  //     //   _log_finder_uin: account.ownerWxUin,
  //     //   filePath: this.parasm.video_path,
  //     //   description: this.form.description,
  //     //   link: undefined,
  //     //   shortTitle: undefined,
  //     //   mode: 1,
  //     //   effectiveTime: this.form.publishing_time_choose==1? Math.ceil(this.form.publishing_time/1000) :undefined,
  //     // }
  //     //
  //     //   //先提交到任务队列中   添加队列的逻辑
  //     //   addPublishRecord(args).then(async (res)=>{
  //     //     if(res.code === 200){
  //     //     //使用electron发布
  //     //     let res = await this.serviceInvoke("controller.media.channels",args)
  //     //       console.log(res)
  //     //     }
  //     //   })
  //
  //
  //     //视频发布接口
  //     // await  publishVideo(args).then((res)=>{
  //     //   console.log(res)
  //     // })
  //
  //       //发布视频   视频发布成功后清空form表单数据
  //
  //
  //       //重置参数
  //       this.reset();
  //
  //      // Message.success("发布任务已提交，请在发布记录中查看！")
  //
  // },





  }
};
</script>
<style>

.el-table .checked {
  background: #051226 !important;
  cursor: pointer;
  transition: all .3s;
}

.el-table .noChecked {
  cursor: pointer;
  background: #fcfcfc !important;
}
</style>
